Skip to content

[paramiko] Update to 5.1.* - #16640

Merged
srittau merged 2 commits into
python:mainfrom
hoangchunghien:paramiko-5.1
Oct 29, 2026
Merged

srittau merged 2 commits into
python:mainfrom
hoangchunghien:paramiko-5.1

Conversation

@hoangchunghien

Copy link
Copy Markdown
Contributor

Closes: #16561

stubtest failed on the stubsabot bump with one error: paramiko.kex_mlkem failed to find stubs. paramiko 5.1 adds that module for the mlkem768x25519-sha256 hybrid key exchange (ML-KEM-768 with X25519), and Transport prefers it when it is available.

The new kex_mlkem.pyi follows kex_curve25519.pyi: the two message constants, and KexMLKEM768X25519 with name, hash_algo, transport, the two private keys, is_available, start_kex and parse_next.

mlkem_key holds a cryptography.hazmat.primitives.asymmetric.mlkem.MLKEM768PrivateKey, which only exists from cryptography 48, while these stubs require cryptography>=37.0.0. Rather than raise that floor, I typed it as Incomplete | None with a comment. Happy to switch to the real type and bump the dependency if you prefer.

stubtest for paramiko 5.1, mypy_test.py stubs/paramiko, pyright_test.py stubs/paramiko (with cryptography installed), black, ruff and flake8 pass locally.

@github-actions

This comment has been minimized.

Comment thread stubs/paramiko/paramiko/kex_mlkem.pyi Outdated
Comment on lines +9 to +10
c_MSG_KEX_HYBRID_INIT: bytes
c_MSG_KEX_HYBRID_REPLY: bytes

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
c_MSG_KEX_HYBRID_INIT: bytes
c_MSG_KEX_HYBRID_REPLY: bytes
c_MSG_KEX_HYBRID_INIT: Final = b"\x1e"
c_MSG_KEX_HYBRID_REPLY: Final = b"\x1f"

Comment thread stubs/paramiko/paramiko/kex_mlkem.pyi Outdated
c_MSG_KEX_HYBRID_REPLY: bytes

class KexMLKEM768X25519:
name: str

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: str
name: Final = "mlkem768x25519-sha256"

Comment thread stubs/paramiko/paramiko/kex_mlkem.pyi Outdated

class KexMLKEM768X25519:
name: str
hash_algo: Callable[[ReadableBuffer], _Hash]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hash_algo: Callable[[ReadableBuffer], _Hash]
hash_algo: ClassVar[Callable[[ReadableBuffer], _Hash]]

Comment thread stubs/paramiko/paramiko/kex_mlkem.pyi Outdated
hash_algo: Callable[[ReadableBuffer], _Hash]
transport: Transport
# cryptography.hazmat.primitives.asymmetric.mlkem.MLKEM768PrivateKey, added in cryptography 48
mlkem_key: Incomplete | None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mlkem_key: Incomplete | None
mlkem_key: MLKEM768PrivateKey | None

This needs import from from cryptography.hazmat.primitives.asymmetric. This also requires cryptography >= 47.0.0. I think it's fine to bump the dependency in METADATA.toml.

@hoangchunghien

Copy link
Copy Markdown
Contributor Author

Thanks, all four applied. I checked the versions: cryptography.hazmat.primitives.asymmetric.mlkem first ships in 47.0.0 (it is missing in 46.0.0), so the comment I had saying 48 was wrong. METADATA.toml now requires cryptography>=47.0.0.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau
srittau merged commit 350a961 into python:main Oct 29, 2026
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants